#include "../import/head.h"
#include "thread_lock.h"
#include "../data_struct/head.h"
#include "../global/head.h"
#include "../macro/head.h"
#include "../msg/head.h"

////////////////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_sgsj
{
    thread_lock::thread_lock()
    {
        g_pSysData->m_os.m_pXos->create( xos::i_xos::XOS_OBJ_MUTX_LOCK, ( void ** )&m_pLock );
    }

    thread_lock::~thread_lock()
    {
        if( m_pLock )
        {
            m_pLock->release();
            m_pLock = 0;
        }
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // 

    int thread_lock::un_lock()
    {
        int ret = 0;

        if( m_pLock )
        {
            m_pLock->un_lock();
        }

        return ret;
    }

    int thread_lock::lock()
    {
        int ret = 0;

        if( m_pLock )
        {
            m_pLock->lock();
        }

        return ret;
    }
} // xos_sgsj
